from django.db import models
from users.models import UserModel
from recommend.models import GoodsModel
from coupon.models import UserCouponModel



# Create your models here.

class OrderModel0(models.Model):
    choice_status = (
        (0,'未支付'),
        (1,'已支付'),
        (2,'已退款'),
        (3, '已发货'),
        (4, '已完成'),
        (5, '已取消'),
    )
    choice_pay_type = (
        (0,'微信支付'),
        (1,'支付宝支付'),
    )
    create_time = models.DateTimeField(auto_now_add=True,verbose_name='创建时间')
    user = models.ForeignKey(UserModel, on_delete=models.DO_NOTHING,db_constraint=False, verbose_name='用户')
    total_price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='总价')
    reduce_price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='优惠价')
    pay_price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='实付款')
    address = models.CharField(max_length=256, verbose_name='收货地址')
    usercoupon = models.ForeignKey(UserCouponModel, on_delete=models.DO_NOTHING,db_constraint=False,null=True,blank=True,verbose_name='用户优惠券')
    pay_type = models.SmallIntegerField(choices=choice_pay_type,default=1, verbose_name='支付方式')
    status = models.SmallIntegerField(choices=choice_status,default=0, verbose_name='订单状态')
    order_id = models.CharField(max_length=128, verbose_name='订单号')
    trade_id = models.CharField(max_length=128, verbose_name='交易号', null=True, blank=True)

    def __str__(self):
        return self.user.username



class OrderModel1(models.Model):
    choice_status = (
        (0,'未支付'),
        (1,'已支付'),
        (2,'已退款'),
        (3, '已发货'),
        (4, '已完成'),
        (5, '已取消'),
    )
    choice_pay_type = (
        (0,'微信支付'),
        (1,'支付宝支付'),
    )
    create_time = models.DateTimeField(auto_now_add=True,verbose_name='创建时间')
    user = models.ForeignKey(UserModel, on_delete=models.DO_NOTHING,db_constraint=False, verbose_name='用户')
    total_price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='总价')
    reduce_price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='优惠价')
    pay_price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='实付款')
    address = models.CharField(max_length=256, verbose_name='收货地址')
    usercoupon = models.ForeignKey(UserCouponModel, on_delete=models.DO_NOTHING,db_constraint=False,null=True,blank=True,verbose_name='用户优惠券')
    pay_type = models.SmallIntegerField(choices=choice_pay_type,default=1, verbose_name='支付方式')
    status = models.SmallIntegerField(choices=choice_status,default=0, verbose_name='订单状态')
    order_id = models.CharField(max_length=128, verbose_name='订单号')
    trade_id = models.CharField(max_length=128, verbose_name='交易号', null=True, blank=True)

    def __str__(self):
        return self.user.username


class OrderModel2(models.Model):
    choice_status = (
        (0,'未支付'),
        (1,'已支付'),
        (2,'已退款'),
        (3, '已发货'),
        (4, '已完成'),
        (5, '已取消'),
    )
    choice_pay_type = (
        (0,'微信支付'),
        (1,'支付宝支付'),
    )
    create_time = models.DateTimeField(auto_now_add=True,verbose_name='创建时间')
    user = models.ForeignKey(UserModel, on_delete=models.DO_NOTHING,db_constraint=False, verbose_name='用户')
    total_price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='总价')
    reduce_price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='优惠价')
    pay_price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='实付款')
    address = models.CharField(max_length=256, verbose_name='收货地址')
    usercoupon = models.ForeignKey(UserCouponModel, on_delete=models.DO_NOTHING,db_constraint=False,null=True,blank=True,verbose_name='用户优惠券')
    pay_type = models.SmallIntegerField(choices=choice_pay_type,default=1, verbose_name='支付方式')
    status = models.SmallIntegerField(choices=choice_status,default=0, verbose_name='订单状态')
    order_id = models.CharField(max_length=128, verbose_name='订单号')
    trade_id = models.CharField(max_length=128, verbose_name='交易号', null=True, blank=True)

    def __str__(self):
        return self.user.username


class OrderGoodsModel0(models.Model):
    user = models.ForeignKey(UserModel, on_delete=models.DO_NOTHING, db_constraint=False, verbose_name='用户')
    order_id = models.CharField(max_length=128, verbose_name='订单号')
    goods = models.ForeignKey(GoodsModel, on_delete=models.DO_NOTHING, db_constraint=False, verbose_name='商品')
    count = models.IntegerField(verbose_name='数量')
    price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='单价')

    def __str__(self):
        return self.user.username


class OrderGoodsModel1(models.Model):
    user = models.ForeignKey(UserModel, on_delete=models.DO_NOTHING, db_constraint=False, verbose_name='用户')
    order_id = models.CharField(max_length=128, verbose_name='订单号')
    goods = models.ForeignKey(GoodsModel, on_delete=models.DO_NOTHING, db_constraint=False, verbose_name='商品')
    count = models.IntegerField(verbose_name='数量')
    price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='单价')

    def __str__(self):
        return self.user.username


class OrderGoodsModel2(models.Model):
    user = models.ForeignKey(UserModel, on_delete=models.DO_NOTHING, db_constraint=False, verbose_name='用户')
    order_id = models.CharField(max_length=128, verbose_name='订单号')
    goods = models.ForeignKey(GoodsModel, on_delete=models.DO_NOTHING, db_constraint=False, verbose_name='商品')
    count = models.IntegerField(verbose_name='数量')
    price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='单价')

    def __str__(self):
        return self.user.username